package com.bosintek.wordtest.gui;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

import com.bosintek.wordtest.Bank;
import com.bosintek.wordtest.R;

public class BankAdapter extends ArrayAdapter<Bank> {

	private ArrayList<Bank> items;

	public BankAdapter(Context context, int textViewResourceId,
			ArrayList<Bank> items) {
		super(context, textViewResourceId, items);
		this.items = items;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		View row = convertView;
		BankItemWrapper wrapper = null;
		if (row == null) {
			LayoutInflater inflater  = (LayoutInflater) getContext().getSystemService(
					Context.LAYOUT_INFLATER_SERVICE);
			row = inflater.inflate(R.layout.bankrow, null);
			wrapper = new BankItemWrapper(row);
			row.setTag(wrapper);
		} else {
			wrapper = (BankItemWrapper) row.getTag();
		}
		wrapper.populateFrom(items.get(position));
		return (row);
	}
}